<?php

/**
 * This is the model class for table "{{setting}}".
 *
 * The followings are the available columns in table '{{setting}}':
 * @property integer $RECORD_ID
 * @property integer $CYCLE_N
 * @property integer $TYPE_N
 * @property string $BAUD_V
 * @property string $PARITY_V
 * @property integer $DATABITS_N
 * @property integer $STOPBITS_N
 */
class Setting extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Setting the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{setting}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('CYCLE_N, TYPE_N, DATABITS_N, STOPBITS_N', 'numerical', 'integerOnly'=>true),
			array('BAUD_V, PARITY_V', 'length', 'max'=>128),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('RECORD_ID, CYCLE_N, TYPE_N, BAUD_V, PARITY_V, DATABITS_N, STOPBITS_N', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'RECORD_ID' => '流水',
			'CYCLE_N' => '采集周期',
			'TYPE_N' => '采集类型',
			'BAUD_V' => '波特率',
			'PARITY_V' => '奇偶校验码',
			'DATABITS_N' => '数据位',
			'STOPBITS_N' => '停止位',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('RECORD_ID',$this->RECORD_ID);
		$criteria->compare('CYCLE_N',$this->CYCLE_N);
		$criteria->compare('TYPE_N',$this->TYPE_N);
		$criteria->compare('BAUD_V',$this->BAUD_V,true);
		$criteria->compare('PARITY_V',$this->PARITY_V,true);
		$criteria->compare('DATABITS_N',$this->DATABITS_N);
		$criteria->compare('STOPBITS_N',$this->STOPBITS_N);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}